using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace LCL.LData {
    /// <summary>
    /// 库
    /// </summary>
    [DebuggerDisplay("{DatabaseName}")]
    [Serializable]
    public class DataBaseModel {
        public DataBaseModel() {
            Tables = new List<TableModel>();
        }
        public string DatabaseName { get; set; }
        public List<TableModel> Tables { get; set; }
    }
    /// <summary>
    /// 表
    /// </summary>
    [DebuggerDisplay("{TableName}")]
    [Serializable]
    public class TableModel {
        public TableModel() {
            Columns = new List<ColumnInfo>();
        }
        public string TableName { get; set; }
        public string TableNameRemark { get; set; }
        public string TablePK { get; set; }
        public bool IsTree { get; set; }
        public List<ColumnInfo> Columns { get; set; }
        public override string ToString() {
            return "Name:" + TableName + " Remark:" + TableNameRemark;
        }
    }
    /// <summary>
    /// 字段
    /// </summary>
    [DebuggerDisplay("{ColumnName}")]
    [Serializable]
    public class ColumnInfo {
        public ColumnInfo(string columnName = "ID",bool isIdentity = true) {
            ColumnName = columnName;
            IsIdentity = isIdentity;
            IsPrimaryKey = false;
            IsIdentity = false;
            Nullable = false;
            Length = "200";
        }
        /// <summary>
        /// 所属表
        /// </summary>
        public string TableName { get; set; }
        public string ColumnOrder { get; set; }
        ///// <summary>
        ///// 字段名称
        ///// </summary>
        public string ColumnName { get; set; }
        ///// <summary>
        ///// 字段类型
        ///// </summary>
        public string TypeName { get; set; }
        public string Length { get; set; }
        public string Precision { get; set; }
        public string Scale { get; set; }
        public bool IsIdentity { get; set; }
        public bool IsPrimaryKey { get; set; }
        public bool IsForeignKey { get; set; }
        public bool Nullable { get; set; }
        /// <summary>
        /// 默认值
        /// </summary>
        public string DefaultVal { get; set; }
        /// <summary>
        /// 字段说明
        /// </summary>
        public string Description { get; set; }
        public override string ToString() {
            return "Name:" + ColumnName + " Remark:" + Description;
        }
    }
    /// <summary>
    ///  表关系
    /// </summary>
    [Serializable]
    public class TableRelation {
        public string FTableName { get; set; }
        public string FColumnsName { get; set; }
        public string RTableName { get; set; }
        public string RColumnsName { get; set; }
        public bool CnstIsUpdateCascade { get; set; }
        public bool CnstIsDeleteCascade { get; set; }
    }
}
